﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace AnimatedSprites
{
    class PauseManager : MenuManager
    {
        public PauseManager(Game1 game)
            : base(game)
        {
            // TODO: Construct any child components here
            // 初始化按键列表通过addSprite   //修改此处以添加按钮
            optionNumber = 3;
            addButtonname("Images//button_resume");
            addButtonname("Images//button_menu");
            addButtonname("Images//button_esc");
        }
        //重写update（）
        public override void Update(GameTime gameTime)
        {
            //检测用户上下按钮输入，更新currentOption的值,如果检测到enter，通过game1掉用其中的currentGameState；
            KeyboardState keyboardState = Keyboard.GetState();

            if (keyboardState.IsKeyDown(Keys.Enter) && !press_e)
            {
                press_e = true;
                switch (currentOption)
                {
                    case 0: game1.setState(1); currentOption = 0; break;        // resume - ingame - 1
                    case 1: game1.setState(0); currentOption = 0; break;        // menu - 0
                    case 2: game1.setState(5); break;                           // exit - 5
                }
            }
            if (keyboardState.IsKeyUp(Keys.Enter))
                press_e = false;
            if (game1.currentGameState == Game1.GameState.GamePaused)
                base.Update(gameTime);
        }
    }
}
